var data  ={};
data.addInfo=(param)=>{
    var _this = param.that;
    var isTrue = param.data;
    func[isTrue](_this)
}
var func={};
 func.ad = (that)=>{
    var selfindex = that.pageInfo.length||0;
    that.pageInfo.forEach(val => {
        val.data.active =false
    });
    that.selfindex =selfindex
    var data ={
        type:"ad",
        data:{
            selfindex:selfindex,
            active:true,
            style:{
                height:"200px"
            },
            datalist:[],
        }
    }
  
    that.pageInfo.push(data)

}
func.goods = that =>{
    //商品模块
    var selfindex = that.pageInfo.length||0;
    that.pageInfo.forEach(val => {
        val.data.active =false
    });
    that.selfindex =selfindex
    var data ={
        type:'goods',
        data:{
                selfindex:selfindex,
                type: '1',
                active: true,
                title: "",
                showtitle: true,
                showprice: true,
                showintro: true,
                default: true,
                datalist: [
                 
                ]
        }
    }
    that.pageInfo.push(data)
}
func.goodslist = that =>{

    var selfindex = that.pageInfo.length||0;
    that.pageInfo.forEach(val => {
        val.data.active =false
    });
    that.selfindex =selfindex
    var data ={
        type:'goodslist',
        data:{
                selfindex:selfindex,
                active: true,
                datalist: [
                 
                ]
        }
    }
    that.pageInfo.push(data)


}
func.notice = (that)=>{
    setfunc(that,'notice')
}
func.line =(that)=>{
    setfunc(that,'line')
}
func.division =(that)=>{
    var n;
    that.pageInfo.forEach(val => {
        console.log(val.data)
        if(val.type =='division'){
                 n = 1
        }
    });
    if(n){
        that.$Message.warning('一个页面只能有一个导航');
        return;
    }else{
        var selfindex = that.pageInfo.length||0;
        that.pageInfo.forEach(val => {
            val.data.active =false
        });
        that.selfindex =selfindex
        var data ={
            type:'division',
            data:{
                selfindex:selfindex,
                active:true,
                title:"",
                color:'#e00',
                datalist:[
                    {
                        title:"首页",
                        link:"0",
                        show:true,
                        on:"i-icon i-icon-homepage_fill",
                        off:"i-icon i-icon-homepage",
                    },
                    {
                        title:"分类",
                        link:"0",
                        show:true,
                        on:"i-icon i-icon-search",
                        off:"i-icon i-icon-searchfill",
                    },
                    {
                        title:"圈子",
                        link:"0",
                        show:true,
                        on:"i-icon i-icon-picture",
                        off:"i-icon i-icon-picture_fill",
                    },
                    {
                        title:"我的",
                        link:"0",
                        show:true,
                        on:"i-icon i-icon-addressbook",
                        off:"i-icon i-icon-addressbook_fill",
                    }
                ],
            }
        }
        that.pageInfo.push(data)
    }
}




var setfunc =(that,title)=>{
    var selfindex = that.pageInfo.length||0;
    that.pageInfo.forEach(val => {
        val.data.active =false
    });
    that.selfindex =selfindex
    var data ={
        type:title,
        data:{
            selfindex:selfindex,
            active:true,
            title:"",
            datalist:[],
        }
    }
    that.pageInfo.push(data)
}
export default data;
